package com.szeldon.declatest.declaration.settings;

import com.szeldon.utils.ValuesUtils;

public class JmsSettingsPartDeclaration extends SettingsDeclaration {

    public static final String REQUIRED_JMS_SERVICE_NAME = "JMS";
    public static final long DEFAULT_TIMEOUT_MILLIS = 60000;

    private String username;
    private String password;
    private String destinationType;
    private String destinationName;
    private String activityType;
    private long timeout;

    /**
     * 
     * @param id
     * @param description
     * @param username
     * @param password
     * @param destinationType
     * @param destinationName
     * @param activityType
     * @param timeout
     *            If null, {@link #DEFAULT_TIMEOUT_MILLIS} is set.
     */
    public JmsSettingsPartDeclaration(String id, String description, String username, String password,
            String destinationType, String destinationName, String activityType, String timeout) {
        super(id, description);
        this.username = ValuesUtils.checkNamedValueForNull("username", username);
        this.password = ValuesUtils.checkNamedValueForNull("password", password);
        this.destinationType = ValuesUtils.checkNamedValueForNull("destinationType", destinationType);
        this.destinationName = ValuesUtils.checkNamedValueForNull("destinationName", destinationName);
        this.activityType = ValuesUtils.checkNamedValueForNull("activityType", activityType);
        if (timeout != null) {
            this.timeout = Long.parseLong(timeout);
        } else {
            this.timeout = DEFAULT_TIMEOUT_MILLIS;
        }
    }

    @Override
    public String getRequiredServiceName() {
        return REQUIRED_JMS_SERVICE_NAME;
    }

    public String getUsername() {
        return username;
    }

    public String getPassword() {
        return password;
    }

    public String getDestinationType() {
        return destinationType;
    }

    public String getDestinationName() {
        return destinationName;
    }

    public static String getRequiredJmsServiceName() {
        return REQUIRED_JMS_SERVICE_NAME;
    }

    public String getActivityType() {
        return activityType;
    }

    public static long getDefaultTimeoutMillis() {
        return DEFAULT_TIMEOUT_MILLIS;
    }

    public long getTimeout() {
        return timeout;
    }

}
